package com.kfm.service;

import com.kfm.dao.SEmpDao;
import com.kfm.model.SEmp;

import java.sql.SQLException;
import java.util.List;

public class SEmpService {

    private SEmpDao dao = new SEmpDao();

    public List<SEmp> findAll() {
        try {
            return dao.selectAll();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public int deleteById(String id) {
        if (id == null) {
            return -1;
        }
        try {
            return dao.deleteById(Integer.parseInt(id));
        } catch (SQLException e) {
            e.printStackTrace();
            return -1;
        }
    }

    public SEmp findById(String id) {
        if (id == null) {
            return null;
        }
        try {
            return dao.selectById(Integer.parseInt(id));
        } catch (SQLException e) {
            e.printStackTrace();
            return null;
        }
    }
}
